<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>新增</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/index.css">
    <script type="text/javascript" src="/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/layui-post.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form action="" method="post" class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label"><span class='x-red'>* </span>所属规格</label>
                <div class="layui-input-block">
                    <select name="parentId" id="parentId" lay-verify="required"><option value="">请选择所属规格</option></select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="spacesName" class="layui-form-label"><span class="x-red">* </span>规格名称</label>
                <div class="layui-input-block">
                    <input type="text" id="spacesName" name="spacesName" required="" lay-verify="required" placeholder="请输入规格名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="price" class="layui-form-label"><span class="x-red">* </span>规格价格</label>
                <div class="layui-input-block">
                    <input type="number" id="price" name="price" required="" lay-verify="required" placeholder="请输入规格价格" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="add">确定</button>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form','laydate'], function(){
        var form = layui.form;
        $.post(geturl()+'/parentSpaces/select?token='+sessionStorage.getItem("token"), JSON.stringify({status:"0"}), function (res) {
            for(var i in res.data) $('#parentId').append('<option value="'+ res.data[i].sysId + '">' + res.data[i].spacesName + '</option>');
            layui.form.render();
        })
        //监听提交
        form.on('submit(add)', function(data){
            layuiPost(geturl()+'/childSpaces/insert?token='+sessionStorage.getItem("token"),data.field,parent.layer.getFrameIndex(window.name));
            return false;
        });
    });
</script>
</body>
</html>